package com.yoomiito.app.utils;

import android.view.View;

import com.yoomiito.app.base.App;

public class SoftKeyBoardUtils {

    public static void showView(View parentView,View bottomView){

        SoftKeyBoardListener.setListener(parentView, new SoftKeyBoardListener.OnSoftKeyBoardChangeListener() {
            @Override
            public void keyBoardShow(int height) {
                int[] s = new int[2];
                parentView.getLocationOnScreen(s);
                int bot = App.mHeightPx - (bottomView.getBottom() + s[1]);
                int scrollY = height - bot;
                if (scrollY > 0) {
                    parentView.scrollTo(0, scrollY);
                }
            }

            @Override
            public void keyBoardHide(int height) {
                if (parentView != null)
                    parentView.scrollTo(0, 0);
            }
        });
    }

    public static void removeListener(){
        SoftKeyBoardListener.removeListener();
    }
}
